package org.delphy.indy2.controls
{
	import flash.events.MouseEvent;
	
	public class CarbonToggleButton extends CarbonButton
	{
		
		private var upColor:Number;
		
		public function CarbonToggleButton()
		{
			super();
			
			toggle=true;
			styleName="carbonToggleButton";
			
			addEventListener(MouseEvent.CLICK,onClick);			
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			
		}
		
		override protected function commitProperties():void{
			super.commitProperties();
			
			upColor=getStyle("color");
			
			if(selected){
				setStyle("color",getStyle("textSelectedColor"));
			}
			
		}
		
		private function onClick(evt:MouseEvent):void{
			if(selected){
				setStyle("color",getStyle("textSelectedColor"));
			}
			else{
				setStyle("color",upColor);
			}
			
		}
		
	}
}